What is gsap?
GSAP (GreenSock Animation Platform) is a powerful JavaScript library for creating high-performance animations that work in all major browsers. It is widely used for animating web elements, SVGs, and more, providing a rich set of features for developers to create complex animations with ease.
What are gsap's main functionalities?
Basic Tweening
This feature allows you to animate any property of an element over a specified duration. In this example, the element with the class 'element' will move 100 pixels to the right over 1 second.
gsap.to('.element', { duration: 1, x: 100 });
Timeline Animations
Timelines allow you to sequence multiple animations. In this example, 'element1' will move 100 pixels to the right, and then 'element2' will move 100 pixels down, each over 1 second.
const tl = gsap.timeline();
tl.to('.element1', { duration: 1, x: 100 })
.to('.element2', { duration: 1, y: 100 });
Stagger Animations
Staggering allows you to animate multiple elements with a delay between each start. In this example, each element with the class 'elements' will move 100 pixels to the right, starting 0.2 seconds after the previous one.
gsap.to('.elements', { duration: 1, x: 100, stagger: 0.2 });
ScrollTrigger
ScrollTrigger allows you to create animations that are triggered by scrolling. In this example, the element with the class 'element' will move 100 pixels to the right when it enters the viewport.
gsap.registerPlugin(ScrollTrigger);
gsap.to('.element', { scrollTrigger: '.element', x: 100 });
Other packages similar to gsap
animejs
Anime.js is a lightweight JavaScript animation library with a simple, yet powerful API. It supports CSS properties, SVG, DOM attributes, and JavaScript Objects. Compared to GSAP, Anime.js is more lightweight but may lack some of the advanced features and plugins that GSAP offers.
velocity-animate
Velocity is an animation engine with the same API as jQuery's $.animate(). It works with and without jQuery. Velocity is known for its performance and ease of use, but it doesn't offer as many features and plugins as GSAP.
popmotion
Popmotion is a functional, flexible JavaScript animation library. It provides a range of tools for creating animations and interactions. While it is highly modular and flexible, it may require more setup and understanding compared to GSAP's more straightforward API.
GSAP (GreenSock Animation Platform)
Ultra high-performance, professional-grade animation for the modern web
GSAP is a JavaScript library for creating high-performance animations that work in every major browser. No other library delivers such advanced sequencing, reliability, API efficiency, and tight control while solving real-world problems on over 4 million sites. GSAP works around countless browser inconsistencies; your animations 'just work'. CSS properties, SVG, canvas libraries, custom properties of generic objects, colors, strings...animate anything! At its core, GSAP is a high-speed property manipulator, updating values over time with extreme accuracy. It's up to 20x faster than jQuery! See the "Why GSAP?" article for what makes GSAP so special.
Full documentation
What is GSAP? (video)
Getting started video
Unlike monolithic frameworks that dictate how you structure your apps, GSAP is completely flexible; sprinkle it wherever you want. React, Vue, Angular or vanilla JS - doesn't matter. Simply put, GSAP is the most robust high-performance animation library on the planet, which is probably why every major ad network excludes it from file size calculations.
Zero dependencies.
This is the public repository for GreenSock's JavaScript tools like GSAP and Draggable. "GSAP" describes all of the animation-related tools which include TweenLite, TweenMax, TimelineLite, TimelineMax, various plugins, extra easing functions, etc.
CDN
TweenMax is most popular because it has all the essential tools plus several common plugins, all in one file:
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.5/TweenMax.min.js"></script>
Click the green "Download GSAP" button at greensock.com for more options. Click "customize" at the bottom of the resulting window to see all the extra plugins and tool URLs.
Draggable, for example, is at:
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.5/utils/Draggable.min.js"></script>
Most ad networks have GSAP on their CDNs as well, so contact them for the appropriate URL(s).
NPM
See the full guide to using GSAP via NPM.
npm install gsap
The default (main) file is TweenMax which includes TweenLite, TimelineLite, TimelineMax, all of the eases (except CustomEase/CustomWiggle/CustomBounce) and the following plugins: css, roundProps, bezier, attr, and directionalRotation.
import {TweenMax, Power2, TimelineLite} from "gsap/TweenMax";
import Draggable from "gsap/Draggable";
import ScrollToPlugin from "gsap/ScrollToPlugin";
For Club GreenSock-only plugins, download them from your GreenSock.com account and then treat them as part of your own JS payload or drop them into your node_modules/gsap folder. Post other questions in our forums and we'd be happy to help.
Resources
Get CustomEase for free
Sign up for a free GreenSock account to gain access to CustomEase which lets you create literally any ease imaginable (unlimited control points). It's in the download zip at GreenSock.com (when you're logged in).
What is Club GreenSock? (video)
Sign up anytime.
Advanced playback controls & debugging
GSDevTools adds a visual UI for controlling your GSAP animations which can significantly boost your workflow and productivity. (Club GreenSock membership required, not included in this repository).
Try all bonus plugins for free on Codepen
https://codepen.io/GreenSock/full/OPqpRJ/
Need help?
GreenSock forums are an excellent resource for learning and getting your questions answered. Report any bugs there too please (it's also okay to file an issue on Github if you prefer).
License
GreenSock's standard "no charge" license can be viewed at http://greensock.com/standard-license. Club GreenSock members are granted additional rights. See http://greensock.com/licensing/ for details. Why doesn't GreenSock use an MIT (or similar) open source license, and why is that a good thing? This article explains it all: http://greensock.com/why-license/
Copyright (c) 2008-2018, GreenSock. All rights reserved.